﻿function GetDiscussions(title, success, failure) {
    var url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists?$select=Title,DefaultViewUrl&$filter=EntityTypeName eq 'DiscussList'";
    //var url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('" + title + "')/items?$filter=ContentTypeId eq '0x01200200BDF31FFC64AB18408FC261A513FD49E8'&$top=10";
    $.ajax({
        url:url,
        method: "GET",
        headers: { "Accept": "application/json; odata=verbose" },
        success: function (data) {
            //success(data);
        },
        error: function (data) {
            //failure(data);
        }
    });
}

function GetDocuments(title, success, failure) {
    var apiUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/";
    $.ajax({
        url: apiUrl + "/web/lists/getbytitle('" + title + "')/items?$select=EncodedAbsUrl",
        method: "GET",
        headers: { "Accept": "application/json; odata=verbose" },
        success: function (data) {
            //success(data);
        },
        error: function (data) {
            //failure(data);
        }
    });
}

function GetPictures(title, success, failure) {
    var apiUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/";
    $.ajax({
        url: apiUrl + "/web/lists/getbytitle('" + title + "')/items?$select=EncodedAbsUrl",
        method: "GET",
        headers: { "Accept": "application/json; odata=verbose" },
        success: function (data) {
            $.each(data.d.results, function (i, result) {
                var path = result.EncodedAbsUrl;
            });
        },
        error: function (data) {
            //failure(data);
        }
    });
}

function GetLinks(title) {
    var apiUrl = "/sites/Team/_api/";
    $.ajax({
        url: apiUrl + "/web/lists/getbytitle('" + title + "')/items?$select=URL&$top=3",
        method: "GET",
        headers: { "Accept": "application/json; odata=verbose" },
        success: function (data) {
            //success(data);
        },
        error: function (data) {
            //failure(data);
        }
    });
}